
package com.jf.cloud.product.controller.platform;

import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.product.service.SpuExtensionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @author zz
 * @Date 2021/7/19 15:32
 */
@RestController("platformSpuExtensionController")
@RequestMapping("/p/spuExtension")
@Tag(name = "platform-spuExtension信息")
public class SpuExtensionController {

    @Autowired
    private SpuExtensionService spuExtensionService;

    @PutMapping("/water_sold_num")
    @Operation(summary = "更新商品注水销量" , description = "更新商品注水销量")
    public ServerResponseEntity<Void> updateWaterSoldNum(@RequestParam(value = "waterSoldNum") Integer waterSoldNum, @RequestParam(value = "spuId") Long spuId) {
        if (Objects.isNull(waterSoldNum)) {
            waterSoldNum = 0;
        }
        spuExtensionService.updateWaterSoldNumBySpuId(spuId, waterSoldNum);
        return ServerResponseEntity.success();
    }
}
